package com.example.spring_boot.Schedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Date;


@Component
public class schedule {
    @Scheduled(cron = "0/2 * * * * ?")
    public void sceduleMod() {
        System.out.println("hello:" + new Date());
        String sql = "insert into user values(null,'小红',123456,'维护',18,'女','河南财政金融学院')";
        addUser();
    }
    @Autowired
    JdbcTemplate jdbcTemplate;
    @GetMapping("/api/user")
    public String addUser(){
        String sql="insert into springboot-vue.user(id,username,password,nick_name,age,sex,address) values(null,'小红',123456,'维护',18,'女','河南财政金融学院')";
        jdbcTemplate.update(sql);
        return "ok";
    }





}
